package com.yuanxiao.common.api.base;

import cn.hutool.json.JSONUtil;
import com.yuanxiao.common.api.entity.dto.UserStaffDTO;
import com.yuanxiao.common.api.entity.dto.UserMemberDTO;
import com.yuanxiao.common.web.util.JwtUtils;

/**
 * Manager Controller 公共组件
 */
public abstract class StaffBaseController {
    //protected Logger logger = LoggerFactory.getLogger (getClass ());

    /*protected UserStaffDTO getStaff() {
        UserStaffDTO staffInfo = new UserStaffDTO();
        staffInfo.setId(1510928673606205440L);
        staffInfo.setCreatorId(0L);
        staffInfo.setCreator("root");
        staffInfo.setDeptId(0L);
        staffInfo.setDeptIds(",0,");
        staffInfo.setCreateTime(new Date ());
        staffInfo.setEditorId(0L);
        staffInfo.setEditor("root");
        staffInfo.setHeaderImg("https://lzshmall-test.oss-cn-chengdu.aliyuncs.com/2022-04-04/79b9b957-b215-48b3-8192-e3007239b0dd_cjs.jpg");
        staffInfo.setName("张三");
        staffInfo.setMobilePhone("15200000000");
        staffInfo.setIdNo("530302198602250698");
        staffInfo.setIdImg("https://lzshmall-test.oss-cn-chengdu.aliyuncs.com/2022-04-04/4206ae14-a7eb-49c2-8f0a-24ee9975c98b_gjl.jpeg@@@@https://lzshmall-test.oss-cn-chengdu.aliyuncs.com/2022-04-04/3dbf37c5-f60e-4cca-822f-c4873b601e64_jgl.png");
        staffInfo.setIsFacialRecognitionVerify("Y");
        staffInfo.setDetectInfo("");
        staffInfo.setAddress("云南-德宏-xxxxxx");
        staffInfo.setMedicalExamImg("https://lzshmall-test.oss-cn-chengdu.aliyuncs.com/2022-04-04/595578a3-c05f-40e4-818b-d8fa80373209_dl.png");
        staffInfo.setMedicalExamValidityEnd(DateUtil.parseDate("2025-04-01 23:59:59"));
        staffInfo.setIsExpireStaffLicense("N");
        staffInfo.setDrivingType("C2");
        staffInfo.setWechatOpenId("xxxxxxxx");
        staffInfo.setWechatNick("admin");
        staffInfo.setWechatUnionId("xxxxxxxx");
        staffInfo.setWechatLoginTime(new Date());
        return staffInfo;
    }*/

    protected UserStaffDTO getStaff() {
        return JSONUtil.toBean (JwtUtils.getUserInfoJSON (), UserStaffDTO.class);
    }

    protected UserMemberDTO getUser() {
        return JSONUtil.toBean (JwtUtils.getUserInfoJSON (), UserMemberDTO.class);
    }

    protected boolean judgeDataAuthorityAboutStaffIdArgs(Long staffId) {
        return staffId.longValue() == getStaff().getId().longValue();
    }

    protected boolean judgeDataAuthorityAboutRoleArgs(String roleType) {
        return "business".equals(roleType);
    }

}
